package org.dtrd.modules.record.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.extern.slf4j.Slf4j;
import org.dtrd.common.util.DateUtils;
import org.dtrd.modules.record.entity.bean.DailyKetoneRecordBean;

import javax.persistence.*;
import java.text.ParseException;
import java.util.Date;

@Slf4j
@Table(name = "dtrd_ent_rd_signin_ketone")
public class DtrdEntRdSigninKetone {
    @Id
    @Column(name = "data_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Integer dataId;

    @Column(name = "patient_id")
    private Integer patientId;

    /**
     * 记录日期
     */
    @Column(name = "record_date")
    private Date recordDate;

    /**
     * 记录时间
     */
    @Column(name = "record_time")
    private Date recordTime;

    /**
     * 尿酮描述
     */
    @Column(name = "ketone_describe")
    private String ketoneDescribe;

    /**
     * 尿酮值(1-5)
     */
    @Column(name = "ketone_value")
    private Integer ketoneValue;

    /**
     * 备注
     */
    @Column(name = "ketone_remark")
    private String ketoneRemark;

    /**
     * 记录类型, 0-打卡, 1-建档
     */
    private Integer ketoneRecordArchiveTag;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "is_del")
    private Integer isDel;

    /**
     * 照片以 竖线 | 拼接
     */
    @Column(name = "record_photo")
    private String recordPhoto;

    public Integer getKetoneRecordArchiveTag() {
        return ketoneRecordArchiveTag;
    }

    public void setKetoneRecordArchiveTag(Integer ketoneRecordArchiveTag) {
        this.ketoneRecordArchiveTag = ketoneRecordArchiveTag;
    }

    /**
     * @return data_id
     */
    public Integer getDataId() {
        return dataId;
    }

    /**
     * @param dataId
     */
    public void setDataId(Integer dataId) {
        this.dataId = dataId;
    }

    /**
     * @return patient_id
     */
    public Integer getPatientId() {
        return patientId;
    }

    /**
     * @param patientId
     */
    public void setPatientId(Integer patientId) {
        this.patientId = patientId;
    }

    /**
     * 获取记录日期
     *
     * @return record_date - 记录日期
     */
    public Date getRecordDate() {
        return recordDate;
    }

    /**
     * 设置记录日期
     *
     * @param recordDate 记录日期
     */
    public void setRecordDate(Date recordDate) {
        this.recordDate = recordDate;
    }

    /**
     * 获取记录时间
     *
     * @return record_time - 记录时间
     */
    public Date getRecordTime() {
        return recordTime;
    }

    /**
     * 设置记录时间
     *
     * @param recordTime 记录时间
     */
    public void setRecordTime(Date recordTime) {
        this.recordTime = recordTime;
    }

    /**
     * 获取尿酮描述
     *
     * @return ketone_describe - 尿酮描述
     */
    public String getKetoneDescribe() {
        return ketoneDescribe;
    }

    /**
     * 设置尿酮描述
     *
     * @param ketoneDescribe 尿酮描述
     */
    public void setKetoneDescribe(String ketoneDescribe) {
        this.ketoneDescribe = ketoneDescribe;
    }

    /**
     * 获取尿酮值(1-5)
     *
     * @return ketone_value - 尿酮值(1-5)
     */
    public Integer getKetoneValue() {
        return ketoneValue;
    }

    /**
     * 设置尿酮值(1-5)
     *
     * @param ketoneValue 尿酮值(1-5)
     */
    public void setKetoneValue(Integer ketoneValue) {
        this.ketoneValue = ketoneValue;
    }

    /**
     * 获取备注
     *
     * @return ketone_remark - 备注
     */
    public String getKetoneRemark() {
        return ketoneRemark;
    }

    /**
     * 设置备注
     *
     * @param ketoneRemark 备注
     */
    public void setKetoneRemark(String ketoneRemark) {
        this.ketoneRemark = ketoneRemark;
    }

    /**
     * @return create_time
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @param createTime
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @return is_del
     */
    public Integer getIsDel() {
        return isDel;
    }

    /**
     * @param isDel
     */
    public void setIsDel(Integer isDel) {
        this.isDel = isDel;
    }

    /**
     * 获取照片以 竖线 | 拼接
     *
     * @return record_photo - 照片以 竖线 | 拼接
     */
    public String getRecordPhoto() {
        return recordPhoto;
    }

    /**
     * 设置照片以 竖线 | 拼接
     *
     * @param recordPhoto 照片以 竖线 | 拼接
     */
    public void setRecordPhoto(String recordPhoto) {
        this.recordPhoto = recordPhoto;
    }

    public DtrdEntRdSigninKetone init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }

    public DtrdEntRdSigninKetone parseFromDTO(DailyKetoneRecordBean dto) {
        this.setDataId(dto.getDataId());
        this.setPatientId(dto.getPatientId());
        this.setKetoneValue(dto.getKetoneValue());
        try {
            if (dto.getRecordTime() != null) {
                this.setRecordDate(DateUtils.parseDate(dto.getRecordTime(), DateUtils.date_sdf.get().toPattern()));
                this.setRecordTime(DateUtils.parseDate(dto.getRecordTime(), DateUtils.datetimeFormat.get().toPattern()));
            }
        } catch (ParseException e) {
            e.printStackTrace();
            log.error("DtrdEntRdSigninKetone.parseFromDTO 日期失败: {}", dto.getRecordTime());
        }
        this.setKetoneDescribe(dto.getKetoneDescribe());
        this.setKetoneRemark(dto.getKetoneRemark());
        this.setRecordPhoto(dto.getKetoneRecordPhoto());
        return this;
    }
}